<%@page import="com.itwill.ecom.cart.CartBeans"%>
<%@page import="org.springframework.web.context.support.WebApplicationContextUtils"%>
<%@page import="org.springframework.web.context.WebApplicationContext"%>
<%@page import="com.itwill.ecom.cart.CartService"%>
<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<% 


WebApplicationContext webApplicationContext = WebApplicationContextUtils.getWebApplicationContext(application);
CartService cartService = (CartService)webApplicationContext.getBean("cartService");

/*
String sid = (String)session.getAttribute("sid");
if(sid == null){ //세션이 안잡혀있을 때
	response.sendRedirect("/ecom/member/loginform");
}
*/

int issame=Integer.parseInt(String.valueOf(request.getAttribute("issame")));//중복인지판단변수
int sid_no=Integer.parseInt(String.valueOf(request.getAttribute("sid_no")));
int no=Integer.parseInt(request.getParameter("product_no"));
int count = Integer.parseInt(request.getParameter("count"));

if(issame==1){//중복일경우
	response.sendRedirect("/ecom/product/productDetail?productno="+no+"&issame=1");
	return;
}

cartService.createCart(new CartBeans(1,sid_no,no,count));

response.sendRedirect("/ecom/product/productDetail?productno="+no+"&issame=2");
return;
%>